package com.neuedu.springmvc.controller;

import com.neuedu.springmvc.po.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 金山
 * 项目：springmvc-learn
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/3/1714:35
 *
 *
 * RestController   === Controller  + ResponseBody
 */
// @Controller
// @ResponseBody


@RestController
@RequestMapping("/rest")
public class MyRestController {





    @RequestMapping("/req4")
    public String req4( ){


        User user = new User();
        user.setUsername("admin");
        user.setPassword("1234567");

        return "{\"name\":\""+user.getUsername()+"\",\"age\":19}";
    }

    @RequestMapping("/req5")
    public User req5( ){
        User user = new User();
        user.setUsername("admin");
        user.setPassword("1234567");


        return user;
    }

    @RequestMapping("/req6")
    public List<User> req6( ){

        List userList = new ArrayList();
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setUsername("admin");
            user.setPassword("1234567");
            userList.add(user);

        }
        return userList;
    }




}
